<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>商品详情</title>
	<link href="${pageContext.request.contextPath }/client/css/main.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css">
</head>
<body>
	<%@include file="./include/head.jsp" %>
	<%@include file="./include/menu_search.jsp" %>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

	<div class="container">
		<div class="jumbotron" style="margin-top: 25px;">
		  <div class="container">
		  	<div class="row">
		  		<div class="col-md-4">
		  			<div class="thumbnail">
		  				<img src="${product.getImgurl()}" style="width: 200px;height: auto;" />
		  			</div>
		  		</div>
		  		<div class="col-md-8">
		  			<h3>
		  				<span class="label label-danger">自营</span>
	  					<span style="padding-left: 5px;vertical-align: middle;">${product.getName()}</span>
	  				</h3>
	  				<ul class="list-group">
					  <li class="list-group-item">分类：${product.getCategory()}</li>
					  <li class="list-group-item">价格：${product.getPrice()}</li>
					  <li class="list-group-item">库存：${product.getPnum()}</li>
					</ul>
		  		</div>
		  	</div>
		  	<div class="clearfix">
		  		<c:if test="${sessionScope._username != null}">
					<c:if test="${collected}">
						<a href="${pageContext.request.contextPath}/DeleteCollectionServlet?pid=${product.getId()}&&cid=${collection.getId()}" class="btn btn-danger pull-right">取消收藏</a>
					</c:if>
					<c:if test="${!collected}">
						<a href="${pageContext.request.contextPath}/AddCollectionServlet?pid=${product.getId()}" class="btn btn-success pull-right">收藏商品</a>
					</c:if>
				</c:if>
		  		<form action="${pageContext.request.contextPath}/AddShoppingCartServlet" method="post" class="pull-right" style="margin-right: 10px;">
		  			<input type="hidden" name="id" value="<c:out value="${product.getId()}" />">
		  			<input type="hidden" name="imgurl" value="<c:out value="${product.getImgurl()}" />">
		  			<input type="hidden" name="PName" value="<c:out value="${product.getName()}" />">
		  			<input type="hidden" name="Price" value="<c:out value="${product.getPrice()}" />">
		  			<input type="hidden" name="PNum" value="<c:out value="${product.getPnum()}" />">
		  			<button type="submit" class="btn btn-default">加入购物车</button>
		  		</form>
		  		<form action="${pageContext.request.contextPath}/PurchaseServlet" method="get" class="form-inline pull-right" style="margin-right: 10px;">
		  			<input type="hidden" name="from" value="product" />
		  			<input type="hidden" name="pid" value="<c:out value="${product.getId()}" />" />
		  			<div class="form-group">
						<label>数量：</label>
						<input type="number" name="select" class="form-control" value="1" style="width: 80px;" min="1" max="${product.getPnum()}" required>
					</div>
		  			<button type="submit" class="btn btn-primary">立即购买</button>
		  		</form>
		  	</div>
		  </div>
		</div>
		<div class="panel panel-default">
			<div class="panel-heading">
				商品详情
			</div>
			<div class="panel-body">
				<p>${product.getDescription()}</p>
			</div>
		</div>
	</div>
	
	<%@include file="./include/foot.jsp" %>
</body>
</html>